package com.goodving.guli.activity;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.MenuItem;

import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.eventbus.EventApkupgrade;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.fragment.dF;
import com.goodving.guli.utility.gulihardware.Constant;
import com.goodving.guli.view.C3657a;

import cn.com.smartdevices.bracelet.config.Config;
import de.greenrobot.event.EventBus;

/**
 * Created by john on 2015/12/25.
 */
public class SettingAboutActivity extends SystemBarTintActivity {
    private static final String f9243a = "SettingAboutActivity";
    private dF f9244b;
    private BroadcastReceiver f9245c;
    private Config f9246d;

    public SettingAboutActivity() {
        this.f9244b = null;
        this.f9246d = Config.m8876h();
    }

    class dE extends BroadcastReceiver {
        final /* synthetic */ SettingAboutActivity f9851a;

        dE(SettingAboutActivity settingAboutActivity) {
            this.f9851a = settingAboutActivity;
        }

        public void onReceive(Context context, Intent intent) {
            GuliLog.tracePrintInfo("intent", C3657a.f18328f + intent.getLongExtra("extra_download_id", 0));
            Utils.m8038b(this.f9851a);
        }
    }

    private void m14065a() {
        this.f9245c = new dE(this);
        registerReceiver(this.f9245c, new IntentFilter("android.intent.action.DOWNLOAD_COMPLETE"));
        EventBus.getDefault().register(this);
    }

    protected boolean isExceptForMiNote() {
        return true;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Bundle bundleExtra = getIntent().getBundleExtra(Constant.aN);
        FragmentTransaction beginTransaction = getFragmentManager().beginTransaction();
        this.f9244b = (dF) Fragment.instantiate(this, dF.class.getName(), bundleExtra);
        beginTransaction.add(16908290, this.f9244b);
        beginTransaction.commit();
        m14065a();
    }

    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(this.f9245c);
        this.f9245c = null;
        EventBus.getDefault().unregister(this);
    }

    public void onEvent(EventApkupgrade eventApkupgrade) {
        GuliLog.tracePrintInfo(f9243a, "onEvent force=" + eventApkupgrade.isForceCheck() + " HasWindowfocus=" + hasWindowFocus());
        if (hasWindowFocus()) {
            Utils.m8039b((Activity) this, eventApkupgrade.isForceCheck());
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    protected void onPause() {
        super.onPause();
        C0668a.m8138b((Activity) this);
    }

    protected void onResume() {
        super.onResume();
        C0668a.m8124a((Activity) this);
    }

    protected void onSaveInstanceState(Bundle bundle) {
    }
}
